home *** CD-ROM | disk | FTP | other *** search
/ Champak 138 / Volume 138 Aug 19 2011 - Damaged.iso / Games / shadez.swf / scripts / Local / Audio / CAudio.as next >
Text File  |  2011-08-19  |  5KB  |  177 lines

  1. package Local.Audio
  2. {
  3.    import Local.CGlobal;
  4.    import flash.events.Event;
  5.    import flash.events.EventDispatcher;
  6.    import flash.geom.Point;
  7.    import flash.geom.Rectangle;
  8.    import flash.media.SoundTransform;
  9.    
  10.    public class CAudio extends EventDispatcher
  11.    {
  12.        
  13.       
  14.       private var mSampleLibrary:Object;
  15.       
  16.       private var mSoundChannels:Object;
  17.       
  18.       public var mScopeSize:Number;
  19.       
  20.       public var mScreenArea:Rectangle;
  21.       
  22.       public var mScreenCentre:Point;
  23.       
  24.       private var mActiveSounds:Object;
  25.       
  26.       public function CAudio()
  27.       {
  28.          if(true)
  29.          {
  30.             super();
  31.             if(true)
  32.             {
  33.                mSampleLibrary = new Object();
  34.                mSoundChannels = new Object();
  35.             }
  36.             mActiveSounds = new Object();
  37.          }
  38.       }
  39.       
  40.       public static function PlayGlobalSound(param1:Class, param2:Number = 1, param3:Number = 0, param4:int = 0, param5:int = 0) : void
  41.       {
  42.          if(true)
  43.          {
  44.             if(!CGlobal.mSoundActive)
  45.             {
  46.                if(true)
  47.                {
  48.                   return;
  49.                }
  50.             }
  51.             new param1().play(param4,param5,new SoundTransform(param2,param3));
  52.          }
  53.       }
  54.       
  55.       public function AddSound(param1:String, param2:Class, param3:int = 0, param4:int = 0, param5:int = 1) : void
  56.       {
  57.          if(mSampleLibrary[param1])
  58.          {
  59.             return;
  60.          }
  61.          mSampleLibrary[param1] = new CSample(param1,param2,param3,param4,param5);
  62.       }
  63.       
  64.       public function Pause() : void
  65.       {
  66.          var _loc1_:CSoundChannel = null;
  67.          for each(_loc1_ in mSoundChannels)
  68.          {
  69.             _loc1_.Pause();
  70.          }
  71.       }
  72.       
  73.       private function e_SOUND_DISPOSING(param1:Event = null) : void
  74.       {
  75.          var _loc2_:CSound = null;
  76.          _loc2_ = CSound(param1.currentTarget);
  77.          delete mActiveSounds[_loc2_.mID];
  78.       }
  79.       
  80.       public function PlaySound(param1:String, param2:*) : String
  81.       {
  82.          var _loc3_:CSound = null;
  83.          var _loc4_:CSoundChannel = null;
  84.          _loc3_ = new CSound(this,mSampleLibrary[param1],!!param2 ? param2 : {
  85.             "nVolume":1,
  86.             "nPan":0
  87.          });
  88.          _loc4_ = !!mSoundChannels[_loc3_.mSampleID] ? mSoundChannels[_loc3_.mSampleID] : (mSoundChannels[_loc3_.mSampleID] = new CSoundChannel());
  89.          mActiveSounds[_loc3_.mID] = _loc3_;
  90.          _loc4_.AddSound(_loc3_);
  91.          if(!_loc4_.hasEventListener(CSoundChannel.DISPOSING))
  92.          {
  93.             _loc4_.addEventListener(CSoundChannel.DISPOSING,e_SOUNDCHANNEL_DISPOSING);
  94.          }
  95.          _loc3_.addEventListener(CSound.DISPOSING,e_SOUND_DISPOSING);
  96.          return _loc3_.mID;
  97.       }
  98.       
  99.       public function StopSound(param1:String) : void
  100.       {
  101.          if(mActiveSounds[param1])
  102.          {
  103.             mActiveSounds[param1].mChannel.RemoveSound(mActiveSounds[param1]);
  104.             delete mActiveSounds[param1];
  105.          }
  106.       }
  107.       
  108.       public function StopAllSounds() : void
  109.       {
  110.          var _loc1_:CSoundChannel = null;
  111.          for each(_loc1_ in mSoundChannels)
  112.          {
  113.             _loc1_.Dispose();
  114.          }
  115.       }
  116.       
  117.       public function Update(param1:Rectangle) : void
  118.       {
  119.          var _loc2_:CSoundChannel = null;
  120.          mScreenArea = param1;
  121.          mScreenCentre = new Point(mScreenArea.x + mScreenArea.width / 2,mScreenArea.y + mScreenArea.height / 2);
  122.          mScopeSize = 1000;
  123.          for each(_loc2_ in mSoundChannels)
  124.          {
  125.             if(true)
  126.             {
  127.                _loc2_.Update();
  128.             }
  129.          }
  130.       }
  131.       
  132.       public function SoundExists(param1:String) : Boolean
  133.       {
  134.          ┬º┬ºpush(mSampleLibrary[param1] == null);
  135.          if(true)
  136.          {
  137.             ┬º┬ºpush(!┬º┬ºpop());
  138.          }
  139.          return ┬º┬ºpop();
  140.       }
  141.       
  142.       public function Resume() : void
  143.       {
  144.          var _loc1_:CSoundChannel = null;
  145.          for each(_loc1_ in mSoundChannels)
  146.          {
  147.             _loc1_.Resume();
  148.          }
  149.       }
  150.       
  151.       private function e_SOUNDCHANNEL_DISPOSING(param1:Event = null) : void
  152.       {
  153.          var _loc2_:CSoundChannel = null;
  154.          var _loc3_:CSound = null;
  155.          _loc2_ = CSoundChannel(param1.currentTarget);
  156.          for each(_loc3_ in _loc2_.mSounds)
  157.          {
  158.             delete mActiveSounds[_loc3_.mID];
  159.          }
  160.          if(true)
  161.          {
  162.             delete mSoundChannels[_loc2_.mSampleID];
  163.          }
  164.       }
  165.       
  166.       public function GetSound(param1:String) : CSound
  167.       {
  168.          return mActiveSounds[param1];
  169.       }
  170.       
  171.       public function Dispose() : void
  172.       {
  173.          StopAllSounds();
  174.       }
  175.    }
  176. }
  177.